#ifndef __SHELL_CMD_H__
#define __SHELL_CMD_H__

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
static inline int exec_shell_cmd(char * command, int delay)
{
	int ret;
	FILE *fp;

	fp = popen(command, "r");
	if (NULL == fp) {
		printf("command:[%s], popen fail!\n", command);
		return -1;
	}

	if (delay > 0)
		sleep(delay);

	ret = pclose(fp);
	if (ret == -1){
		printf("command:[%s], pclose fail!\n", command);
		return -1;
	}

	if (WIFEXITED(ret) == 0) {
		printf("command:[%s], command exec fail!\n", command);
		return -1;
	}

	return 0;
}

#endif /* __SHELL_CMD_H__ */
